/**
 * Created by Administrator on 2017/4/6.
 */
/*选择游戏界面，该方法在prechoose方法最后一行被调用*/
function choose() {
    var x=320,y=202,game=1;
    choose_arrow(x,y);
    document.body.onkeydown=function (e) {
        if(e.which==83){
            choose_arrow(x,y==202+150?y=202:y=y+50);
        }else if(e.which==87){
            choose_arrow(x,y==202?y=202+150:y=y-50);
        }
        switch (y){
            case 202:game=1;break;
            case 252:game=2;break;
            case 302:game=3;break;
            case 352:game=4;break;
        }
       // console.log(game);
        if(e.which==13){
            /*销毁事件*/
            document.body.onkeydown=null;
            if(game==2)game2();
            else if(game==3)game3();
            else if(game==4)game4();
            else game1();
        }
    };
    function choose_arrow(arrowX,arrowY) {
        ogc.clearRect(0,0,og.width,og.height);
        //window.console.log("choose开始执行");
        ogc.font = "30px Courier New";
        ogc.fillStyle = "#000";
        ogc.fillText("Ⅰ.加纳战机", 350, 200);
        ogc.fillText("Ⅱ.炸弹人  ", 350, 250);
        ogc.fillText("Ⅲ.超级玛丽", 350, 300);
        ogc.fillText("Ⅳ.热血格斗", 350, 350);
        ogc.beginPath();
        ogc.moveTo(arrowX,arrowY);
        ogc.lineTo(arrowX+4,arrowY-15);
        ogc.lineTo(arrowX,arrowY-30);
        ogc.lineTo(arrowX+20,arrowY-15);
        ogc.fillStyle='#f00';
        ogc.fill();
        ogc.closePath();
    }

}
